<?php

namespace addons\formdesign;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Formdesign extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name' => 'formdesign/form',
                'title' => '表单设计',
                'icon' => 'fa fa-pencil-square-o',
                'remark' => '自定义表单设计器，支持拖拽排序，自识别控件自动生成数据表form_data_XXX,适用于构建调查问卷、简单记录等',
                'sublist' => [
                    ['name' => 'formdesign/form/index', 'title' => '查看'],
                    ['name' => 'formdesign/form/add', 'title' => '添加'],
                    ['name' => 'formdesign/form/edit', 'title' => '编辑 '],
                    ['name' => 'formdesign/form/del', 'title' => '删除'],
                    ['name' => 'formdesign/form/multi', 'title' => '批量更新'],
                ],
            ],
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete('formdesign/form');
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable('formdesign/form');
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable('formdesign/form');
        return true;
    }
}
